<template>
	<view>
		<view class="item box-padding box-color u-m-b-20" v-for="(item, index) in shopList" :key="index">
			<view>
				<text class="u-font-32">{{ item.name }}</text>
			</view>
			<view class="u-flex u-row-between u-m-t-30">
				<text style="font-size: 26rpx;color: #666666;">地址：{{ item.address }}</text>
				<text v-if="item.state == 0" class="u-font-26 badge-color">待审批</text>
				<text v-if="item.state == 9" class="u-font-26 grey-color">已拒绝</text>
				<text v-if="item.state == 1" class="u-font-26" style="color: #348F3B;">审批通过</text>
			</view>
		</view>
	</view>
</template>

<script>
	import { useShopStore } from '@/store/shop.js';
	import { useUserStore } from '@/store/user.js';
	import { mapState } from 'pinia';
	export default {
		data() {
			return {
				shopList: []
			}
		},
		onLoad() {
			// 获取门店列表
			this.getShopList()
		},
		computed:{
			...mapState(useShopStore, {shopLogin: 'login'}),
			...mapState(useUserStore, {storeUser: 'user'})
		},
		methods: {
			async getShopList() {
				const res = await this.$http.get('api/Shop/GetShopByUserId', { params: { id: this.storeUser.id } })
				if (!res) return
				this.shopList = res
			},
			getState(state) {
				let stateText = ''
				switch(state) {
					case 0:
						stateText = '审核中';
						break;
					case 1:
						stateText = '已审核';
						break;
					default:
						stateText = '审核中';
				}
				return stateText
			},
			async switchShop() {
				const res = await this.$http.get('api/Shop/GetShop', { params: { id: this.shopIndex.id } })
				// console.log(this.shopIndex)
				await this.shopLogin(res)
				await this.$mHelper.getTabbar()
				this.$mRouter.reLaunch({ route: '/pages/purchase/index' })
			}
		}
	}
</script>

<style lang="scss" scoped>
	.item {
		
	}
</style>
